﻿using JzSport.Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace JzSport.Api
{
    /// <summary>
    /// 获取个人的活动列表
    /// </summary>
    class GetActivityCount4UserAction : AuthGetAction<Params.GetActivityCount4UserParams,
        Results.GetActivityCount4UserResult>
    {
        protected override ActionResult<Results.GetActivityCount4UserResult> OnExecute(ActionContext context,
            SysParameters sysParameters,
            Params.GetActivityCount4UserParams opParams)
        {
            ActivityService service = new ActivityService();
            
            Results.GetActivityCount4UserResult actionResult = new Results.GetActivityCount4UserResult();
            actionResult.FinishedCount = service.GetFinishedActivityCount4User(context.AccountId).Data;
            actionResult.UnfinishedCount = service.GetUnfinishedActivityCount4User(context.AccountId).Data;
            actionResult.CreatedCount = service.GetUnfinishedActivityCount4Creator(context.AccountId).Data;

            return new ActionResult<Results.GetActivityCount4UserResult>("1.0.1", true, ErrorCode.NoError,
                        ErrorCode.ToString(ErrorCode.NoError), actionResult);
        }
    }
}
